<template>
	<body-wrap>
		<view class="comment">
			<navigator class="cmList" v-for="dt in lists" :key="dt._id" :url="`/pages/qa/detail?id=${dt._id}`">
				<view class="imgbox">
					<cm-image v-if="dt.userId" :src="dt.userId.avatar"/>
				</view>
				<view class="mainbox">
					<text class="name">{{dt.userId.name || dt.userId.nickname}}</text>
					<text class="time">{{dateFormat('Y-m-d H:i',dt.createTime)}}</text>
					<view class="cmDtBox">{{dt.questionContent}}</view>
					<!-- <view class="zjhf">
						<text class="title">专家回复</text>
						<view class="replayCon"></view>
					</view> -->
					<view class="opbox">
						<i class="iconfont icon-chakan">{{dt.reads}}</i>
						<i class="iconfont icon-31pinglun">{{dt.comments}}</i>
						<i class="iconfont icon-shoucang">{{dt.collects}}</i>
					</view>
				</view>
			</navigator>
		</view>
	</body-wrap>
</template>

<script>
	import {defineComponent,reactive,toRefs,onMounted,getCurrentInstance,computed} from 'vue'
	import {onLoad,onShow} from '@dcloudio/uni-app'
	import { useStore } from 'vuex'
	import cmImage from "@/components/cmImage/index.vue"
	import {getQuestionList} from "@/api/consult.js"
	import {dateFormat,toast} from "@/utils/common.js"
	export default defineComponent({
		components:{
			cmImage
		},
		props:{
		
		},
		setup(props,context) {
			const store = useStore()
			const {proxy} = getCurrentInstance()
			
			const state = reactive({
				userInfo:computed(()=>store.state.base.userInfo),
				lists:'',
				pageIndex:1,
				pageSize:20,
				kwd:''
			})
			
			onMounted(()=>{
				getQaList()
			})
			
			const getQaList = async ()=>{
				const res = await getQuestionList({
					userId:state.userInfo._id,
					pageIndex:state.pageIndex,
					pageSize:state.pageSize,
					from:'EJConsult',
					keywords:state.kwd
				})
				state.lists = res.data.data || []
			}
			
			return {
				...toRefs(state),
				dateFormat
			}
		}
	})
</script>

<style lang="scss" scoped>
	.comment{
		padding: 0;
		box-sizing: border-box;
		width: 100%;
		.cmList{
			display: flex;
			box-sizing: border-box;
			padding: 20rpx;
			background: #fff;
			&+.cmList{
				border-top: 1px solid #f2f2f2;
			}
			.imgbox{
				width: 100rpx;
				height: 100rpx;
				border-radius: 50%;
				overflow: hidden;
				flex-shrink: 0;
			}
			.mainbox{
				flex: 1;
				box-sizing: border-box;
				flex-shrink: 0;
				padding: 0 0 0 10rpx;
				line-height: normal;
				width: 100%;
				.name{
					display: block;
					font-size: 32rpx;
					color: #e3af2f;
				}
				.time{
					display: block;
					font-size: 28rpx;
					color: #999;
					padding: 15rpx 0;
				}
				.cmDtBox{
					font-size: 28rpx;
					line-height: 46rpx;
				}
				.zjhf{
					background: #f7f6f2;
					padding: 15rpx;
					border-radius: 10rpx;
					margin: 10rpx 0 0 0;
					.title{
						display: block;
						font-size: 30rpx;
						font-weight: bold;
						color: #b47a48;
						padding: 0 0 10rpx 0;
					}
					.replayCon{
						font-size: 28rpx;
						line-height: 46rpx;
						color: #b47a48;
					}
				}
				.opbox{
					display: flex;
					align-items: center;
					justify-content: flex-end;
					padding: 15rpx 0 0 0;
					.iconfont{
						font-size: 26rpx;
						color: #999;
						&+.iconfont{
							margin-left: 20rpx;
						}
						&:before{
							font-size: 30rpx;
							color: #333;
							font-weight: 700;
						}
					}
				}
			}
		}
	}
</style>

